var $window = window;
let allowedHosts = "localhost:5000,127.0.0.1:3000,dts.xwsjsc.com";

const AsciiToString = code => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        return String.fromCharCode(code);
    },
    checkLumingAuto = () => {
        // let encryptedText = "867466c8432f000b0bbd04c3b6584edc8501e87533d166b7da320113e6dd703f0c7650d8d0218279d75cf3d4f4044b8b647853d1048b27f0",
        //     host = $window.location.host,
        //     decryptedHost = monkeyWalkT(encryptedText);

        // if (!decryptedHost) {
        //     return {
        //         lumingauto: false
        //     };
        // }

        // if (allowedHosts != decryptedHost) {
        //     return {
        //         lumingauto: false
        //     };
        // }

        // if (allowedHosts.split(",").indexOf(host) == -1) {
        //     return {
        //         lumingauto: false
        //     };
        // }

        return {
            lumingauto: true
        };
    };

window.alert = function (msg) {
    var str = "";

    for (var i = 0; i < msg.length; i += 1) {
        var s = msg.charAt(i);

        if (s === "+") {
            str += " ";
        } else {
            if (s === "%") {
                var hex = msg.substring(i + 1, i + 3);

                if (parseInt("0x" + hex) > 127) {
                    str += decodeURI("%" + hex.toString() + msg.substring(i + 3, i + 9).toString());
                    i += 8;
                } else {
                    str += AsciiToString(parseInt("0x" + hex));
                    i += 2;
                }
            } else {
                str += s;
            }
        }
    }

    return false;
};

const urlDecode = url => {
        var decodedString = "";

        for (var i = 0; i < url.length; i += 1) {
            var currentChar = url.charAt(i);

            if (currentChar === "+") {
                decodedString += " ";
            } else {
                if (currentChar === "%") {
                    var hexSubstring = url.substring(i + 1, i + 3);

                    if (parseInt("0x" + hexSubstring) > 127) {
                        decodedString += decodeURI("%" + hexSubstring.toString() + url.substring(i + 3, i + 9).toString());
                        i += 8;
                    } else {
                        decodedString += AsciiToString(parseInt("0x" + hexSubstring));
                        i += 2;
                    }
                } else {
                    decodedString += currentChar;
                }
            }
        }

        if (!checkLumingAuto().lumingauto) {
            return;
        }
        console.log(1,'urlDecode');

        return decodedString;
    },
    getUrlParams = url => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        var queryString = decodeURI(location.search),
            paramsObject = {};

        if (queryString.indexOf("?") != -1) {
            var paramsString = queryString.substr(1),
                paramsArray = paramsString.split("&");

            for (var i = 0; i < paramsArray.length; i++) {
                paramsObject[paramsArray[i].split("=")[0]] = paramsArray[i].split("=")[1];
            }
        }

        return paramsObject[url];
    },
    getFactor = e => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        return $window.innerWidth / e.image.width;
    },
    initBackground = (backgroundObject, scaleFactor) => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        const scaleProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        backgroundObject.set(scaleProperties);

        backgroundObject.x = 0;
        backgroundObject.y = 0;
        return backgroundObject;
    },
    initTitle = (titleImage, scaleFactor) => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        const scaleProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let titleBitmap = new createjs.Bitmap(titleImage).set(scaleProperties);

        titleBitmap.x = 0;
        titleBitmap.y = 140 * scaleFactor;
        return titleBitmap;
    },
    initMyInputContainer = (containerImage, contentImage, scaleFactor) => {
        let inputContainer = new createjs.Container();

        inputContainer.x = 50 * scaleFactor;
        inputContainer.y = containerImage.y + containerImage.image.height * scaleFactor + 50 * scaleFactor;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        const contentImageProperties = {
            scaleX: scaleFactor * 0.6,
            scaleY: scaleFactor * 0.6
        };

        let contentBitmap = new createjs.Bitmap(contentImage).set(contentImageProperties);

        inputContainer.addChild(contentBitmap);

        let textElement = new createjs.Text("0", "bold " + 60 * scaleFactor + "px Arial", "#FFFFFF");

        textElement.shadow = new createjs.Shadow("#000000", 2, 0, 1);
        textElement.x = contentBitmap.image.width * scaleFactor * 0.6 + 40 * scaleFactor;
        textElement.y = 20 * scaleFactor;

        inputContainer.addChild(textElement);

        return inputContainer;
    },
    initJoinBoxContainer = (containerImage, iconImages, langGetter, scaleFactor) => {
        const containerProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let iconBitmap = new createjs.Bitmap(iconImages[0]).set(containerProperties),
            joinBoxContainer = new createjs.Container();

        joinBoxContainer.x = $window.innerWidth - (iconBitmap.image.width + 20) * scaleFactor;
        joinBoxContainer.y = containerImage.y + 150 * scaleFactor;

        joinBoxContainer.addChild(iconBitmap);

        let langText = new createjs.Text("0" + langGetter("lang1"), 34 * scaleFactor + "px Arial", "#FFFFFF");

        langText.x = 20 * scaleFactor;
        langText.y = 25 * scaleFactor;

        joinBoxContainer.addChild(langText);

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let lang2Text = new createjs.Text(langGetter("lang2"), 34 * scaleFactor + "px Arial", "#FFFFFF");

        lang2Text.x = langText.x + 200 * scaleFactor;
        lang2Text.y = langText.y;

        joinBoxContainer.addChild(lang2Text);

        const iconProperties = {
            scaleX: scaleFactor - 0.1,
            scaleY: scaleFactor - 0.1
        };

        let secondIconBitmap = new createjs.Bitmap(iconImages[1]).set(iconProperties);

        secondIconBitmap.x = 20 * scaleFactor;
        secondIconBitmap.y = langText.y + 80 * scaleFactor;

        joinBoxContainer.addChild(secondIconBitmap);

        let ratioText = new createjs.Text("0/0", 40 * scaleFactor + "px Arial", "#FFFFFF");

        ratioText.x = langText.x + 270 * scaleFactor;
        ratioText.y = langText.y + 90 * scaleFactor;

        joinBoxContainer.addChild(ratioText);

        return joinBoxContainer;
    },
    initEvadedFail = (failImage, langGetter, scaleFactor) => {
        let evadedFailContainer = new createjs.Container();

        evadedFailContainer.x = 0;
        evadedFailContainer.y = 0;
        evadedFailContainer.alpha = 0;

        let overlayGraphics = new createjs.Graphics().beginFill("#00000077").drawRect(0, 0, $window.innerWidth, document.body.clientHeight),
            overlayShape = new createjs.Shape(overlayGraphics);

        evadedFailContainer.addChild(overlayShape);

        const imageProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let failImageBitmap = new createjs.Bitmap(failImage).set(imageProperties);

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        failImageBitmap.x = $window.innerWidth / 2 - failImageBitmap.image.width * scaleFactor / 2;
        failImageBitmap.y = $window.innerHeight / 2 - failImageBitmap.image.height * scaleFactor / 2;

        evadedFailContainer.addChild(failImageBitmap);

        let failText = new createjs.Text(langGetter("lang20"), "bold " + 60 * scaleFactor + "px Arial", "#FFFFFF");

        failText.x = $window.innerWidth / 2 - failText.getMeasuredWidth() / 2;
        failText.y = failImageBitmap.y + 310 * scaleFactor;
        failText.shadow = new createjs.Shadow("#FF0000", 2, 2, 1);

        evadedFailContainer.addChild(failText);

        return evadedFailContainer;
    },
    initEvadedSuccess = (successImage, langGetter, scaleFactor) => {
        let evadedSuccessContainer = new createjs.Container();

        evadedSuccessContainer.x = 0;
        evadedSuccessContainer.y = 0;
        evadedSuccessContainer.alpha = 0;

        let overlayGraphics = new createjs.Graphics().beginFill("#00000055").drawRect(0, 0, $window.innerWidth, document.body.clientHeight),
            overlayShape = new createjs.Shape(overlayGraphics);

        evadedSuccessContainer.addChild(overlayShape);

        const imageProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let successImageBitmap = new createjs.Bitmap(successImage).set(imageProperties);

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        successImageBitmap.x = $window.innerWidth / 2 - successImageBitmap.image.width * scaleFactor / 2;
        successImageBitmap.y = $window.innerHeight / 2 - successImageBitmap.image.height * scaleFactor / 2;

        evadedSuccessContainer.addChild(successImageBitmap);

        let successText = new createjs.Text(langGetter("lang18"), "bold " + 60 * scaleFactor + "px Arial", "#FFFFFF");

        successText.x = $window.innerWidth / 2 - successText.getMeasuredWidth() / 2;
        successText.y = successImageBitmap.y + 310 * scaleFactor;
        successText.shadow = new createjs.Shadow("#00FF00", 2, 2, 1);

        evadedSuccessContainer.addChild(successText);

        return evadedSuccessContainer;
    },
    initEvadedWait = (waitImage, langGetter, killerAmount, scaleFactor) => {
        let evadedWaitContainer = new createjs.Container();

        evadedWaitContainer.x = 0;
        evadedWaitContainer.y = 0;
        evadedWaitContainer.alpha = 0;

        let overlayGraphics = new createjs.Graphics().beginFill("#00000077").drawRect(0, 0, $window.innerWidth, document.body.clientHeight),
            overlayShape = new createjs.Shape(overlayGraphics);

        evadedWaitContainer.addChild(overlayShape);

        const imageProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let waitImageBitmap = new createjs.Bitmap(langGetter).set(imageProperties);

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        waitImageBitmap.x = $window.innerWidth / 2 - waitImageBitmap.image.width * scaleFactor / 2;
        waitImageBitmap.y = $window.innerHeight / 2 - waitImageBitmap.image.height * scaleFactor / 2;

        evadedWaitContainer.addChild(waitImageBitmap);

        let killerAmountText = new createjs.Text(killerAmount("lang17") + (" " + waitImage.total_killer_amount), "bold " + 40 * scaleFactor + "px Arial", "#FFFFFF");

        killerAmountText.x = 450 * scaleFactor;
        killerAmountText.y = waitImageBitmap.y + 200 * scaleFactor;

        evadedWaitContainer.addChild(killerAmountText);

        return evadedWaitContainer;
    },
    initHomeMedal = (medalIndex, medalImage, medalPositions, scaleFactor) => {
        let medalX,
            medalY,
            medalPosition = medalPositions[medalIndex - 1];

        switch (medalIndex) {
            case 1:
                medalX = medalPosition.x + 20 * scaleFactor;
                medalY = medalPosition.y + 60 * scaleFactor;
                break;

            case 2:
                medalX = medalPosition.x + 20 * scaleFactor;
                medalY = medalPosition.y + 80 * scaleFactor;
                break;

            case 3:
                medalX = medalPosition.x + 20 * scaleFactor;
                medalY = medalPosition.y + 110 * scaleFactor;
                break;

            case 4:
                medalX = medalPosition.x + 20 * scaleFactor;
                medalY = medalPosition.y + 60 * scaleFactor;
                break;

            case 5:
                medalX = medalPosition.x + 20 * scaleFactor;
                medalY = medalPosition.y + 60 * scaleFactor;
                break;

            case 6:
                medalX = medalPosition.x + 20 * scaleFactor;
                medalY = medalPosition.y + 60 * scaleFactor;
                break;

            case 7:
                medalX = medalPosition.x + 20 * scaleFactor;
                medalY = medalPosition.y + 60 * scaleFactor;
                break;

            case 8:
                medalX = medalPosition.x + 20 * scaleFactor;
                medalY = medalPosition.y + 60 * scaleFactor;
                break;
        }

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let medalContainer = new createjs.Container();

        medalContainer.x = medalX;
        medalContainer.y = medalY;
        const medalImageProperties = {
            scaleX: scaleFactor * 0.4,
            scaleY: scaleFactor * 0.4
        };

        let medalBitmap = new createjs.Bitmap(medalImage).set(medalImageProperties),
            medalAmounts = [0, 0, 0, 0, 0, 0, 0, 0];

        medalContainer.addChild(medalBitmap);

        let amountText = new createjs.Text(medalAmounts[medalIndex - 1].amount || 0, "bold " + 50 * scaleFactor + "px Arial", "#FFFFFF");

        amountText.x = medalBitmap.image.width * scaleFactor * 0.4 + 10 * scaleFactor;
        amountText.y = 6 * scaleFactor;
        amountText.shadow = new createjs.Shadow("#000000", 2, 2, 1);

        medalContainer.addChild(amountText);

        return medalContainer;
    },
    initHovel = (hovelImage, scaleFactor) => {
        const hovelImageProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let hovelBitmap = new createjs.Bitmap(hovelImage).set(hovelImageProperties);

        hovelBitmap.x = 0;
        hovelBitmap.y = 510 * scaleFactor;
        hovelBitmap.alpha = 0;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        hovelBitmap.x_s = hovelBitmap.x;
        hovelBitmap.x_e = hovelBitmap.x + hovelBitmap.image.width * scaleFactor;
        hovelBitmap.y_s = hovelBitmap.y;
        hovelBitmap.y_e = hovelBitmap.y + hovelBitmap.image.height * scaleFactor;
        return hovelBitmap;
    },
    initHovelText = (hovelTextImage, scaleFactor) => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        const hovelTextImageProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let hovelTextBitmap = new createjs.Bitmap(hovelTextImage).set(hovelTextImageProperties);

        hovelTextBitmap.x = 0;
        hovelTextBitmap.y = 510 * scaleFactor;
        hovelTextBitmap.alpha = 0;
        return hovelTextBitmap;
    },
    initOffice = (officeImage, scaleFactor) => {
        const officeImageProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let officeBitmap = new createjs.Bitmap(officeImage).set(officeImageProperties);

        officeBitmap.x = $window.innerWidth - officeBitmap.image.width * scaleFactor;
        officeBitmap.y = 520 * scaleFactor;
        officeBitmap.alpha = 0;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        officeBitmap.x_s = officeBitmap.x;
        officeBitmap.x_e = officeBitmap.x + officeBitmap.image.width * scaleFactor;
        officeBitmap.y_s = officeBitmap.y;
        officeBitmap.y_e = officeBitmap.y + officeBitmap.image.height * scaleFactor;
        return officeBitmap;
    },
    initOfficeText = (officeTextImage, scaleFactor) => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        const officeTextImageProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let officeTextBitmap = new createjs.Bitmap(officeTextImage).set(officeTextImageProperties);

        officeTextBitmap.x = $window.innerWidth - officeTextBitmap.image.width * scaleFactor;
        officeTextBitmap.y = 520 * scaleFactor;
        officeTextBitmap.alpha = 0;
        return officeTextBitmap;
    },
    initLounge = (loungeImage, scaleFactor, hovelDimensions) => {
        const loungeImageProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let loungeBitmap = new createjs.Bitmap(loungeImage).set(loungeImageProperties);

        loungeBitmap.x = (hovelDimensions.hovel.image.width + 20) * scaleFactor;
        loungeBitmap.y = 600 * scaleFactor;
        loungeBitmap.alpha = 0;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        loungeBitmap.x_s = loungeBitmap.x;
        loungeBitmap.x_e = loungeBitmap.x + loungeBitmap.image.width * scaleFactor;
        loungeBitmap.y_s = loungeBitmap.y;
        loungeBitmap.y_e = loungeBitmap.y + loungeBitmap.image.height * scaleFactor;
        return loungeBitmap;
    },
    initLoungeText = (loungeTextImage, scaleFactor, hovelDimensions) => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        const loungeTextProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let loungeTextBitmap = new createjs.Bitmap(loungeTextImage).set(loungeTextProperties);

        loungeTextBitmap.x = (hovelDimensions.hovel.image.width + 20) * scaleFactor;
        loungeTextBitmap.y = 600 * scaleFactor;
        loungeTextBitmap.alpha = 0;
        return loungeTextBitmap;
    },
    initSpeak = (scaleFactor, assets) => {
        const speakProperties = {
            scaleX: scaleFactor,
            scaleY: scaleFactor
        };

        let speakBitmap = new createjs.Bitmap(assets.loader.getResult("speak")).set(speakProperties);

        speakBitmap.x = 0;
        speakBitmap.y = (assets.hovel.image.height + 520) * scaleFactor;
        speakBitmap.alpha = 0;
        speakBitmap.x_s = speakBitmap.x;
        speakBitmap.x_e = speakBitmap.x + speakBitmap.image.width * scaleFactor;
        speakBitmap.y_s = speakBitmap.y;
        speakBitmap.y_e = speakBitmap.y + speakBitmap.image.height * scaleFactor;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        return speakBitmap;
    },
    initSpeakText = assets => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let speakTextBitmap = new createjs.Bitmap(assets.loader.getResult("speakText_" + assets.lang)).set({
            scaleX: assets.factor,
            scaleY: assets.factor
        });

        speakTextBitmap.x = 0;
        speakTextBitmap.y = (assets.hovel.image.height + 520) * assets.factor;
        speakTextBitmap.alpha = 0;
        return speakTextBitmap;
    },
    initLaundry = assets => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let laundryBitmap = new createjs.Bitmap(assets.loader.getResult("laundry")).set({
            scaleX: assets.factor,
            scaleY: assets.factor
        });

        laundryBitmap.x = (assets.speak.image.width + 20) * assets.factor;
        laundryBitmap.y = (assets.hovel.image.height + 710) * assets.factor;
        laundryBitmap.alpha = 0;
        laundryBitmap.x_s = laundryBitmap.x;
        laundryBitmap.x_e = laundryBitmap.x + laundryBitmap.image.width * assets.factor;
        laundryBitmap.y_s = laundryBitmap.y;
        laundryBitmap.y_e = laundryBitmap.y + laundryBitmap.image.height * assets.factor;
        return laundryBitmap;
    },
    initLaundryText = assets => {
        let laundryTextBitmap    = new createjs.Bitmap(assets.loader.getResult("laundryText_" + assets.lang)).set({
            scaleX: assets.factor,
            scaleY: assets.factor
        });

        laundryTextBitmap.x = (assets.speak.image.width + 20) * assets.factor;
        laundryTextBitmap.y = (assets.hovel.image.height + 710) * assets.factor;
        laundryTextBitmap.alpha = 0;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        return laundryTextBitmap;
    },
    initStudio = assets => {
        let studioBitmap = new createjs.Bitmap(assets.loader.getResult("studio")).set({
            scaleX: assets.factor,
            scaleY: assets.factor
        });

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        studioBitmap.x = $window.innerWidth - studioBitmap.image.width * assets.factor;
        studioBitmap.y = (assets.hovel.image.height + 710) * assets.factor;
        studioBitmap.alpha = 0;
        studioBitmap.x_s = studioBitmap.x;
        studioBitmap.x_e = studioBitmap.x + studioBitmap.image.width * assets.factor;
        studioBitmap.y_s = studioBitmap.y;
        studioBitmap.y_e = studioBitmap.y + studioBitmap.image.height * assets.factor;
        return studioBitmap;
    },
    initStudioText = assets => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let studioTextBitmap = new createjs.Bitmap(assets.loader.getResult("studioText_" + assets.lang)).set({
            scaleX: assets.factor,
            scaleY: assets.factor
        });

        studioTextBitmap.x = $window.innerWidth - assets.studio.image.width * assets.factor;
        studioTextBitmap.y = (assets.hovel.image.height + 710) * assets.factor;
        studioTextBitmap.alpha = 0;
        return studioTextBitmap;
    },
    initTea = assets => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let teaBitmap = new createjs.Bitmap(assets.loader.getResult("tea")).set({
            scaleX: assets.factor,
            scaleY: assets.factor
        });

        teaBitmap.x = 0;
        teaBitmap.y = assets.speak.y + assets.speak.image.height * assets.factor;
        teaBitmap.alpha = 0;
        teaBitmap.x_s = teaBitmap.x;
        teaBitmap.x_e = teaBitmap.x + teaBitmap.image.width * assets.factor;
        teaBitmap.y_s = teaBitmap.y;
        teaBitmap.y_e = teaBitmap.y + teaBitmap.image.height * assets.factor;
        return teaBitmap;
    },
    initTeaText = assets => {
        let teaTextBitmap = new createjs.Bitmap(assets.loader.getResult("teaText_" + assets.lang)).set({
            scaleX: assets.factor,
            scaleY: assets.factor
        });

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        teaTextBitmap.x = 0;
        teaTextBitmap.y = assets.speak.y + assets.speak.image.height * assets.factor;
        teaTextBitmap.alpha = 0;
        return teaTextBitmap;
    },
    initMusic = assets => {
        let musicBitmap = new createjs.Bitmap(assets.loader.getResult("music")).set({
            scaleX: assets.factor,
            scaleY: assets.factor
        });

        musicBitmap.x = (assets.tea.image.width + 20) * assets.factor;
        musicBitmap.y = assets.laundry.y + (assets.laundry.image.height + 180) * assets.factor;
        musicBitmap.alpha = 0;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        musicBitmap.x_s = musicBitmap.x;
        musicBitmap.x_e = musicBitmap.x + musicBitmap.image.width * assets.factor;
        musicBitmap.y_s = musicBitmap.y;
        musicBitmap.y_e = musicBitmap.y + musicBitmap.image.height * assets.factor;
        return musicBitmap;
    },
    initMusicText = assets => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let musicTextBitmap = new createjs.Bitmap(assets.loader.getResult("musicText_" + assets.lang)).set({
            scaleX: assets.factor,
            scaleY: assets.factor
        });

        musicTextBitmap.x = (assets.tea.image.width + 20) * assets.factor;
        musicTextBitmap.y = assets.laundry.y + (assets.laundry.image.height + 180) * assets.factor;
        musicTextBitmap.alpha = 0;
        return musicTextBitmap;
    },
    initDoors = assets => {
        let bigDoor = new createjs.Bitmap(assets.loader.getResult("bigDoor")).set({
                scaleX: assets.factor,
                scaleY: assets.factor
            }),
            doorEntryLeft = new createjs.Bitmap(assets.loader.getResult("doorEntryLeft")).set({
                scaleX: assets.factor,
                scaleY: assets.factor
            }),
            doorEntryRight = new createjs.Bitmap(assets.loader.getResult("doorEntryRight")).set({
                scaleX: assets.factor,
                scaleY: assets.factor
            }),
            doorLeft = new createjs.Bitmap(assets.loader.getResult("doorLeft")).set({
                scaleX: assets.factor,
                scaleY: assets.factor
            }),
            doorRight = new createjs.Bitmap(assets.loader.getResult("doorRight")).set({
                scaleX: assets.factor,
                scaleY: assets.factor
            }),
            doorVertical = new createjs.Bitmap(assets.loader.getResult("doorVertical")).set({
                scaleX: assets.factor,
                scaleY: assets.factor
            });

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let doorContainerBig = new createjs.Container();

        doorContainerBig.x = assets.hovel.x + assets.hovel.image.width * assets.factor - bigDoor.image.width * assets.factor;
        doorContainerBig.y = assets.hovel.y + assets.hovel.image.height * assets.factor;

        assets.stage.addChild(doorContainerBig);

        bigDoor.x = -bigDoor.image.width * assets.factor;

        doorContainerBig.addChildAt(bigDoor, 0);

        doorContainerBig.mask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(doorContainerBig.x, doorContainerBig.y, bigDoor.image.width * assets.factor, bigDoor.image.height * assets.factor));
        assets.doorHovelContaner = doorContainerBig;

        let doorContainerLounge = new createjs.Container();

        doorContainerLounge.x = assets.lounge.x;
        doorContainerLounge.y = assets.lounge.y + assets.lounge.image.height * assets.factor;

        assets.stage.addChild(doorContainerLounge);

        doorLeft.x = 5 * assets.factor - doorLeft.image.width * assets.factor;
        doorLeft.y = 0;

        doorContainerLounge.addChild(doorLeft);

        doorRight.x = 2 * doorLeft.image.width * assets.factor - 5 * assets.factor;
        doorRight.y = 0;

        doorContainerLounge.addChild(doorRight);

        doorContainerLounge.mask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(doorContainerLounge.x, doorContainerLounge.y, doorLeft.image.width * assets.factor * 2, doorLeft.image.height * assets.factor * 2));
        assets.doorLoungeContainer = doorContainerLounge;

        let doorLeftOffice = new createjs.Bitmap(assets.loader.getResult("doorLeft")).set({
                scaleX: assets.factor,
                scaleY: assets.factor
            }),
            doorRightOffice = new createjs.Bitmap(assets.loader.getResult("doorRight")).set({
                scaleX: assets.factor,
                scaleY: assets.factor
            }),
            doorContainerOffice = new createjs.Container();

        doorContainerOffice.x = assets.office.x;
        doorContainerOffice.y = assets.office.y + assets.office.image.height * assets.factor;

        assets.stage.addChild(doorContainerOffice);

        doorLeftOffice.x = 5 * assets.factor - doorLeft.image.width * assets.factor;
        doorLeftOffice.y = 0;

        doorContainerOffice.addChild(doorLeftOffice);

        doorRightOffice.x = 2 * doorLeft.image.width * assets.factor - 5 * assets.factor;
        doorRightOffice.y = 0;

        doorContainerOffice.addChild(doorRightOffice);

        doorContainerOffice.mask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(doorContainerOffice.x, doorContainerOffice.y, doorLeftOffice.image.width * assets.factor * 2, doorLeftOffice.image.height * assets.factor * 2));
        assets.doorOfficeContainer = doorContainerOffice;

        let doorLeftLaundry = doorLeftOffice.clone(),
            doorRightLaundry = doorRightOffice.clone(),
            doorContainerLaundry = new createjs.Container();

        doorContainerLaundry.x = assets.laundry.x + 120 * assets.factor;
        doorContainerLaundry.y = assets.laundry.y + assets.laundry.image.height * assets.factor;

        assets.stage.addChild(doorContainerLaundry);

        doorContainerLaundry.addChild(doorLeftLaundry);

        doorContainerLaundry.addChild(doorRightLaundry);

        doorContainerLaundry.mask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(doorContainerLaundry.x, doorContainerLaundry.y, doorLeftLaundry.image.width * assets.factor * 2, doorLeftLaundry.image.height * assets.factor * 2));
        assets.doorLaundryContainer = doorContainerLaundry;

        let doorLeftMusic = doorLeftOffice.clone(),
            doorRightMusic = doorRightOffice.clone(),
            doorContainerMusic = new createjs.Container();

        doorContainerMusic.x = assets.music.x + 200 * assets.factor;
        doorContainerMusic.y = assets.music.y;

        assets.stage.addChild(doorContainerMusic);

        doorContainerMusic.addChild(doorLeftMusic);

        doorContainerMusic.addChild(doorRightMusic);

        doorContainerMusic.mask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(doorContainerMusic.x, doorContainerMusic.y, doorLeftMusic.image.width * assets.factor * 2, doorLeftMusic.image.height * assets.factor * 2));
        assets.doorMusicContainer = doorContainerMusic;

        let doorContainerSpeak = new createjs.Container();

        doorContainerSpeak.x = assets.speak.x + (assets.speak.image.width - 10) * assets.factor;
        doorContainerSpeak.y = assets.speak.y + 65 * assets.factor;

        assets.stage.addChild(doorContainerSpeak);

        doorVertical.y = 90 * assets.factor;

        doorContainerSpeak.addChild(doorVertical);

        doorContainerSpeak.mask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(doorContainerSpeak.x, doorContainerSpeak.y, doorVertical.image.width * assets.factor, doorVertical.image.height * assets.factor));
        assets.doorSpeakContainer = doorContainerSpeak;

        let doorTeaVertical = doorVertical.clone(),
            doorContainerTea = new createjs.Container();

        doorContainerTea.x = assets.tea.x + (assets.tea.image.width - 10) * assets.factor;
        doorContainerTea.y = assets.tea.y + 70 * assets.factor;

        assets.stage.addChild(doorContainerTea);

        doorTeaVertical.y = 90 * assets.factor;

        doorContainerTea.addChild(doorTeaVertical);

        doorContainerTea.mask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(doorContainerTea.x, doorContainerTea.y, doorTeaVertical.image.width * assets.factor, doorTeaVertical.image.height * assets.factor));
        assets.doorTeaContainer = doorContainerTea;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let doorStudioVertical = doorVertical.clone(),
            doorContainerStudio = new createjs.Container();

        doorContainerStudio.x = assets.studio.x - 31 * assets.factor;
        doorContainerStudio.y = assets.tea.y + 50 * assets.factor;

        assets.stage.addChild(doorContainerStudio);

        doorStudioVertical.y = 90 * assets.factor;

        doorContainerStudio.addChild(doorStudioVertical);

        doorContainerStudio.mask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(doorContainerStudio.x, doorContainerStudio.y, doorStudioVertical.image.width * assets.factor, doorStudioVertical.image.height * assets.factor));
        assets.doorStudioContainer = doorContainerStudio;

        let doorEntryContainer = new createjs.Container();

        doorEntryContainer.x = assets.music.x + (assets.music.image.width + 20) * assets.factor;
        doorEntryContainer.y = assets.music.y + (assets.music.image.height + 0) * assets.factor;

        assets.stage.addChild(doorEntryContainer);

        doorEntryLeft.x = -doorEntryLeft.image.width * assets.factor;

        doorEntryContainer.addChild(doorEntryLeft);

        doorEntryRight.x = (2 * doorEntryLeft.image.width - 5) * assets.factor;

        doorEntryContainer.addChild(doorEntryRight);

        doorEntryContainer.mask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(doorEntryContainer.x, doorEntryContainer.y, doorEntryLeft.image.width * assets.factor * 2, doorEntryLeft.image.height * assets.factor * 2));
        assets.doorContainer = doorEntryContainer;
    },
    initKiller = gameContext => {
        let killerBitmap = new createjs.Bitmap(gameContext.loader.getResult("killer_action_0")),
            killerWidth = killerBitmap.image.width,
            killerHeight = killerBitmap.image.height;

        gameContext.killerWidth = killerWidth;
        gameContext.killerHeight = killerHeight;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        var spriteSheetBuilder = new createjs.SpriteSheetBuilder(),
            framesKill = [];

        for (let i = 0; i < 20; i++) {
            framesKill.push(spriteSheetBuilder.addFrame(new createjs.Bitmap(gameContext.loader.getResult("killer_action_" + i))));
        }

        spriteSheetBuilder.addAnimation("kill", framesKill, "walk");

        var framesWalk = [];

        for (let i = 20; i < 82; i++) {
            framesWalk.push(spriteSheetBuilder.addFrame(new createjs.Bitmap(gameContext.loader.getResult("killer_action_" + i))));
        }

        spriteSheetBuilder.addAnimation("walk", framesWalk, "walk", 0.5);

        let spriteSheet = spriteSheetBuilder.build();

        const scaleOptions = {
            scaleX: gameContext.factor * 0.5,
            scaleY: gameContext.factor * 0.5
        };

        let killerSprite = new createjs.Sprite(spriteSheet, "walk").set(scaleOptions);

        killerSprite.regX = killerWidth / 2;
        killerSprite.regY = killerHeight / 2;
        killerSprite.skewY = -180;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let killerContainer = new createjs.Container();

        killerContainer.x = $window.innerWidth + 100 + gameContext.killerWidth * (gameContext.factor - 0.1);
        killerContainer.y = gameContext.music.y + 30 * gameContext.factor;

        let roundRect = new createjs.Graphics().beginFill("#FF0000").drawRoundRect(0, 0, (gameContext.killerWidth - 40) * gameContext.factor * 0.5, 100 * gameContext.factor * 0.5, 50 * gameContext.factor * 0.5);

        var rectangleShape = new createjs.Shape(roundRect);

        rectangleShape.x = -40 * gameContext.factor;
        rectangleShape.y = -20 * gameContext.factor;

        killerContainer.addChild(rectangleShape);

        let killerText = new createjs.Text(gameContext.$t("lang23"), 25 * gameContext.factor + "px Arial", "#FFFFFF");

        killerText.textAlign = "center";
        killerText.x = 2 * gameContext.factor;
        killerText.y = -8 * gameContext.factor;

        killerText.setBounds(0, 0, gameContext.killerWidth * (gameContext.factor * 0.5), 60 * (gameContext.factor * 0.5));

        killerContainer.addChild(killerText);

        killerSprite.x = 0;
        killerSprite.y = 80 * gameContext.factor;

        killerContainer.addChild(killerSprite);

        gameContext.stage.addChild(killerContainer);

        gameContext.killerContainer = killerContainer;
    },
    initMonkey = (userInfo, walkDelay = 0, gameContext) => {
        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let monkeyKey = "monkey_" + gameContext.info.game_id + "_" + userInfo.user_id;

        if (gameContext.userMonkeys.hasOwnProperty(monkeyKey)) {
            if (!(userInfo.user_id == gameContext.refreshInfo.user_id)) {
                if (!gameContext.userMonkeys[monkeyKey].walk && userInfo.room_id) {
                    gameContext.userMonkeys[monkeyKey].walk = true;
                    gameContext.userMonkeys[monkeyKey].home_id = userInfo.room_id;
                    setTimeout(() => {
                        gameContext.userMonkeyWalk(gameContext.userMonkeys[monkeyKey].target, userInfo.room_id, walkDelay);
                    }, Math.random() * 1000);
                } else {
                    if (gameContext.userMonkeys[monkeyKey].walk && userInfo.room_id != gameContext.userMonkeys[monkeyKey].home_id) {
                        gameContext.userMonkeys[monkeyKey].home_id = userInfo.room_id;

                        if (gameContext.userMonkeys[monkeyKey].walkOver) {
                            gameContext.userMonkeyWalk(gameContext.userMonkeys[monkeyKey].target, userInfo.room_id, 0);
                        }
                    }
                }
            }

            return;
        }

        let monkeyBitmap = new createjs.Bitmap(gameContext.loader.getResult("monkey_0_0")),
            monkeyWidth = monkeyBitmap.image.width,
            monkeyHeight = monkeyBitmap.image.height;

        if (!gameContext.monkeysBuilder) {
            var monkeySpriteSheetBuilder = new createjs.SpriteSheetBuilder(),
                monkeyFrames = [];

            for (let i = 0; i < 60; i++) {
                monkeyFrames.push(monkeySpriteSheetBuilder.addFrame(new createjs.Bitmap(gameContext.loader.getResult("monkey_0_" + i))));
            }

            monkeySpriteSheetBuilder.addAnimation("stand", monkeyFrames, "stand", 0.5);

            gameContext.monkeysBuilder = monkeySpriteSheetBuilder.build();
        }

        let monkeySprite,
            monkeyScale = 1;

        if (!gameContext.userMonkeysTarget) {
            var monkeySpriteSheet = gameContext.monkeysBuilder;
            const monkeyScaleOptions = {
                scaleX: gameContext.factor * 0.4 * monkeyScale,
                scaleY: gameContext.factor * 0.4 * monkeyScale
            };
            monkeySprite = new createjs.Sprite(monkeySpriteSheet, "stand").set(monkeyScaleOptions);
            gameContext.userMonkeysTarget = monkeySprite.clone();
        } else {
            monkeySprite = gameContext.userMonkeysTarget.clone();
        }

        monkeySprite.x = 0;
        monkeySprite.y = 50 * gameContext.factor * monkeyScale;
        monkeySprite.regX = monkeyWidth / 2;
        monkeySprite.regY = monkeyHeight / 2;
        Math.random() * 10 > 5 && (monkeySprite.skewY = -180);

        let monkeyContainer = new createjs.Container();

        monkeyContainer.x = Math.random() * ($window.innerWidth - 200 * gameContext.factor) + 50 * gameContext.factor;
        monkeyContainer.y = gameContext.tea.y + (gameContext.tea.image.height + Math.random() * 100 + 100) * gameContext.factor;
        monkeyContainer.x_o = monkeyContainer.x;
        monkeyContainer.y_o = monkeyContainer.y;

        let monkeyText = new createjs.Text(userInfo.user_id == gameContext.refreshInfo.user_id ? gameContext.$t("lang22") : userInfo.nickname, "bold " + 60 * gameContext.factor * monkeyScale * 0.4 + "px Arial", "#FFFFFF");

        monkeyText.shadow = new createjs.Shadow("#000000", 2, 0, 1);
        monkeyText.textAlign = "center";

        monkeyText.setBounds(0, 0, monkeyWidth * (gameContext.factor * 0.4 * monkeyScale), 20 * gameContext.factor * monkeyScale * 0.4);

        monkeyContainer.addChildAt(monkeyText, 0);

        monkeyContainer.addChildAt(monkeySprite, 1);

        monkeyContainer.flowScale = monkeyScale;
        monkeyContainer.monkeyWidth = monkeyWidth;
        monkeyContainer.monkeyHeight = monkeyHeight;
        monkeyContainer.scale = 0;
        monkeyContainer.user_id = userInfo.user_id;

        gameContext.userMonkeysContainer.addChild(monkeyContainer);

        const monkeyScaleOptions = {
            scale: 1
        };
        createjs.Tween.get(monkeyContainer).to(monkeyScaleOptions, 100);
        userInfo.user_id == gameContext.refreshInfo.user_id && (gameContext.myMonkey = monkeyContainer);
        const monkeyInfo = {
            target: monkeyContainer,
            home_id: userInfo.home_id,
            walk: false,
            walkOver: false,
            user_id: userInfo.user_id,
            out: false
        };
        gameContext.userMonkeys[monkeyKey] = monkeyInfo;

        if (userInfo.room_id && userInfo.user_id != gameContext.refreshInfo.user_id) {
            gameContext.userMonkeys[monkeyKey].walk = true;
            gameContext.userMonkeys[monkeyKey].home_id = userInfo.home_id;
            setTimeout(() => {
                gameContext.userMonkeyWalk(gameContext.userMonkeys[monkeyKey].target, userInfo.room_id, walkDelay);
            }, Math.random() * 1000);
        }

        walkDelay == 0 && userInfo.user_id == gameContext.refreshInfo.user_id && gameContext.homeClick(userInfo.room_id);
    },
    monkeyWalkT = (encryptedText, secretKey) => {
        if (encryptedText == "") {
            return "";
        }

        (!secretKey || secretKey == "") && (secretKey = "luming123000..");
        secretKey = encodeURIComponent(secretKey);

        if (encryptedText == undefined || encryptedText.length < 8) {
            return "";
        }

        if (secretKey == undefined || secretKey.length <= 0) {
            return "";
        }

        var keyString = "";

        for (var i = 0, len = secretKey.length; i < len; i += 1) {
            keyString += secretKey.charCodeAt(i).toString();
        }

        var midIndex = Math.floor(keyString.length / 5),
            magicNumber = parseInt(keyString.charAt(midIndex) + keyString.charAt(midIndex * 2) + keyString.charAt(midIndex * 3) + keyString.charAt(midIndex * 4) + keyString.charAt(midIndex * 5)),
            halfKeyLength = Math.round(secretKey.length / 2),
            maxInt = Math.pow(2, 31) - 1,
            lastHexValue = parseInt(encryptedText.substring(encryptedText.length - 8, encryptedText.length), 16);

        encryptedText = encryptedText.substring(0, encryptedText.length - 8);
        keyString += lastHexValue;

        while (keyString.length > 10) {
            keyString = (parseInt(keyString.substring(0, 10)) + parseInt(keyString.substring(10, keyString.length))).toString();
        }

        keyString = (magicNumber * keyString + halfKeyLength) % maxInt;
        var decryptedText = "",
            currentCharCode = "";

        for (var i = 0, len = encryptedText.length; i < len; i += 2) {
            decryptedText = parseInt(parseInt(encryptedText.substring(i, i + 2), 16) ^ Math.floor(keyString / maxInt * 255));
            currentCharCode += String.fromCharCode(decryptedText);
            keyString = (magicNumber * keyString + halfKeyLength) % maxInt;
        }

        return decodeURIComponent(currentCharCode);
    },
    initBtnActions = gameInfo => {
        let killBtnBitmap = new createjs.Bitmap(gameInfo.loader.getResult("killBtn")).set({
                scaleX: gameInfo.factor,
                scaleY: gameInfo.factor
            }),
            medal1Bitmap = new createjs.Bitmap(gameInfo.loader.getResult("medal1")).set({
                scaleX: gameInfo.factor,
                scaleY: gameInfo.factor
            }),
            container = new createjs.Container();

        container.x = $window.innerWidth / 2 - killBtnBitmap.image.width * gameInfo.factor / 2;
        container.y = gameInfo.tea.y + (gameInfo.tea.image.height + 350) * gameInfo.factor;

        gameInfo.stage.addChild(container);

        let royalMonkeyBitmap = new createjs.Bitmap(gameInfo.loader.getResult("royalMonkey")).set({
            scaleX: gameInfo.factor,
            scaleY: gameInfo.factor
        });

        royalMonkeyBitmap.x = 60 * gameInfo.factor;
        royalMonkeyBitmap.y = -80 * gameInfo.factor;
        gameInfo.royalMonkey = royalMonkeyBitmap;

        container.addChild(royalMonkeyBitmap);

        let descContainer = new createjs.Container();

        descContainer.x = (royalMonkeyBitmap.image.width + 70) * gameInfo.factor;
        descContainer.y = -50 * gameInfo.factor;

        container.addChild(descContainer);

        let roundRect = new createjs.Graphics().beginFill("#FFFFFF").drawRoundRect(0, 0, 470 * gameInfo.factor, 50 * gameInfo.factor, 25 * gameInfo.factor);

        var shape = new createjs.Shape(roundRect);

        descContainer.addChild(shape);

        let text = new createjs.Text(gameInfo.monkeyTalks[0], 30 * gameInfo.factor + "px Arial", "#000000");

        text.x = 30 * gameInfo.factor;
        text.y = 12 * gameInfo.factor;

        descContainer.addChild(text);

        gameInfo.btActionsDescContainer = descContainer;

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let option1Rect = new createjs.Graphics().beginFill("#FFFFFFEE").drawRoundRectComplex(0, 0, 230 * gameInfo.factor, 90 * gameInfo.factor, 25 * gameInfo.factor, 25 * gameInfo.factor, 0, 0),
            option2Rect = new createjs.Graphics().beginFill("#FFFFFFEE").drawRect(0, 0, 230 * gameInfo.factor, 90 * gameInfo.factor),
            option3Rect = new createjs.Graphics().beginFill("#FFFFFFEE").drawRoundRectComplex(0, 0, 230 * gameInfo.factor, 90 * gameInfo.factor, 0, 0, 25 * gameInfo.factor, 25 * gameInfo.factor),
            selectedOptionRect = new createjs.Graphics().beginFill("#ebe3c1EE").drawRoundRectComplex(0, 0, 230 * gameInfo.factor, 90 * gameInfo.factor, 25 * gameInfo.factor, 25 * gameInfo.factor, 0, 0),
            selectedOption2Rect = new createjs.Graphics().beginFill("#ebe3c1EE").drawRect(0, 0, 230 * gameInfo.factor, 90 * gameInfo.factor),
            selectedOption3Rect = new createjs.Graphics().beginFill("#ebe3c1EE").drawRoundRectComplex(0, 0, 230 * gameInfo.factor, 90 * gameInfo.factor, 0, 0, 25 * gameInfo.factor, 25 * gameInfo.factor),
            optionsContainer = new createjs.Container();

        optionsContainer.x = 75 * gameInfo.factor;
        optionsContainer.y = -240 * gameInfo.factor;

        container.addChild(optionsContainer);

        let optionContainer1 = new createjs.Container();

        optionContainer1.x = 0;
        optionContainer1.y = 0;

        optionsContainer.addChild(optionContainer1);

        let optionShape1 = new createjs.Shape(selectedOptionRect);

        optionContainer1.addChild(optionShape1);

        let optionMedal1 = medal1Bitmap.clone();

        optionMedal1.scale = gameInfo.factor * 0.8;
        optionMedal1.x = 30 * gameInfo.factor;
        optionMedal1.y = 15 * gameInfo.factor;

        optionContainer1.addChild(optionMedal1);

        let optionText1 = new createjs.Text(gameInfo.inputMedals[0], 45 * gameInfo.factor + "px Arial", "#000000");

        optionText1.x = (optionMedal1.x + optionMedal1.image.width + 10) * gameInfo.factor;
        optionText1.y = 25 * gameInfo.factor;

        optionContainer1.addChild(optionText1);

        let optionContainer2 = new createjs.Container();

        optionContainer2.x = 0;
        optionContainer2.y = 90 * gameInfo.factor;

        optionsContainer.addChild(optionContainer2);

        let optionShape2 = new createjs.Shape(option2Rect);

        optionContainer2.addChild(optionShape2);

        let optionMedal2 = medal1Bitmap.clone();

        optionMedal2.scale = gameInfo.factor * 0.8;
        optionMedal2.x = 30 * gameInfo.factor;
        optionMedal2.y = 15 * gameInfo.factor;

        optionContainer2.addChild(optionMedal2);

        let optionText2 = new createjs.Text(gameInfo.inputMedals[1], 45 * gameInfo.factor + "px Arial", "#000000");

        optionText2.x = (optionMedal2.x + optionMedal2.image.width + 10) * gameInfo.factor;
        optionText2.y = 25 * gameInfo.factor;

        optionContainer2.addChild(optionText2);

        let optionContainer3 = new createjs.Container();

        optionContainer3.x = 0;
        optionContainer3.y = 180 * gameInfo.factor;

        optionsContainer.addChild(optionContainer3);

        let optionShape3 = new createjs.Shape(option3Rect);

        optionContainer3.addChild(optionShape3);

        let optionMedal3 = medal1Bitmap.clone();

        optionMedal3.scale = gameInfo.factor * 0.8;
        optionMedal3.x = 30 * gameInfo.factor;
        optionMedal3.y = 15 * gameInfo.factor;

        optionContainer3.addChild(optionMedal3);

        let optionText3 = new createjs.Text(gameInfo.inputMedals[2], 45 * gameInfo.factor + "px Arial", "#000000");

        optionText3.x = (optionMedal3.x + optionMedal3.image.width + 10) * gameInfo.factor;
        optionText3.y = 25 * gameInfo.factor;

        optionContainer3.addChild(optionText3);

        optionContainer1.addEventListener("click", e => {
            gameInfo.inputCurMedal = gameInfo.inputMedals[0];
            gameInfo.inputMedalContainer.getChildAt(1).text = gameInfo.inputCurMedal;
            royalMonkeyBitmap.alpha = 1;
            descContainer.alpha = 1;
            gameInfo.inputMedalOptionsContainer.alpha = 0;
            optionShape1.graphics = selectedOptionRect;
            optionShape2.graphics = option2Rect;
            optionShape3.graphics = option3Rect;
        });

        optionContainer2.addEventListener("click", e => {
            gameInfo.inputCurMedal = gameInfo.inputMedals[1];
            gameInfo.inputMedalContainer.getChildAt(1).text = gameInfo.inputCurMedal;
            royalMonkeyBitmap.alpha = 1;
            descContainer.alpha = 1;
            gameInfo.inputMedalOptionsContainer.alpha = 0;
            optionContainer2;
            optionShape1.graphics = option1Rect;
            optionShape2.graphics = selectedOption2Rect;
            optionShape3.graphics = option3Rect;
        });

        optionContainer3.addEventListener("click", e => {
            gameInfo.inputCurMedal = gameInfo.inputMedals[2];
            gameInfo.inputMedalContainer.getChildAt(1).text = gameInfo.inputCurMedal;
            royalMonkeyBitmap.alpha = 1;
            descContainer.alpha = 1;
            gameInfo.inputMedalOptionsContainer.alpha = 0;
            optionShape1.graphics = option1Rect;
            optionShape2.graphics = option2Rect;
            optionShape3.graphics = selectedOption3Rect;
        });

        optionsContainer.alpha = 0;
        gameInfo.inputMedalOptionsContainer = optionsContainer;

        let rect1 = new createjs.Graphics().beginFill("#FF0000").drawRoundRectComplex(0, 0, 240 * gameInfo.factor, 160 * gameInfo.factor, 25 * gameInfo.factor, 0, 0, 25 * gameInfo.factor),
            rect2 = new createjs.Shape(rect1);

        rect2.x = container.x + 70 * gameInfo.factor;
        rect2.y = container.y + 38 * gameInfo.factor;
        rect2.alpha = 0.01;

        gameInfo.stage.addChild(rect2);

        rect2.addEventListener("click", e => {
            if (gameInfo.refreshInfo.state == 3 && gameInfo.refreshInfo.timer == 0) {
                return;
            }

            if (optionsContainer.alpha == 0) {
                royalMonkeyBitmap.alpha = 0;
                descContainer.alpha = 0;
                gameInfo.inputMedalOptionsContainer.alpha = 1;
            } else {
                royalMonkeyBitmap.alpha = 1;
                descContainer.alpha = 1;
                gameInfo.inputMedalOptionsContainer.alpha = 0;
            }
        });

        let rect3 = new createjs.Graphics().beginFill("#FF0000").drawRoundRectComplex(0, 0, 400 * gameInfo.factor, 160 * gameInfo.factor, 0, 25 * gameInfo.factor, 25 * gameInfo.factor, 0),
            rect4 = new createjs.Shape(rect3);

        rect4.x = container.x + 310 * gameInfo.factor;
        rect4.y = container.y + 38 * gameInfo.factor;
        rect4.alpha = 0.01;

        gameInfo.stage.addChild(rect4);

        rect4.addEventListener("click", e => {
            createjs.Sound.play("playClick");

            gameInfo.join(gameInfo.inputCurMedal);
        });

        container.addChild(killBtnBitmap);

        let container2 = new createjs.Container();

        container2.setBounds(0, 0, 400 * gameInfo.factor, 600 * gameInfo.factor);

        container2.x = 90 * gameInfo.factor;
        container2.y = 80 * gameInfo.factor;

        container.addChild(container2);

        container2.addChild(medal1Bitmap);

        let text2 = new createjs.Text(gameInfo.inputCurMedal, 48 * gameInfo.factor + "px Arial", "#FFFFFF");

        text2.x = (medal1Bitmap.image.width + 10) * gameInfo.factor;
        text2.y = 15 * gameInfo.factor;

        container2.addChild(text2);

        let downIcon = new createjs.Bitmap(gameInfo.loader.getResult("downIcon")).set({
            scaleX: gameInfo.factor * 0.6,
            scaleY: gameInfo.factor * 0.6
        });

        downIcon.x = (medal1Bitmap.image.width + 70) * gameInfo.factor;
        downIcon.y = 5 * gameInfo.factor;

        container2.addChild(downIcon);

        gameInfo.inputMedalContainer = container2;

        let text3 = new createjs.Text(gameInfo.$t("lang21"), 60 * gameInfo.factor + "px Arial", "#000000");

        text3.x = 400 * gameInfo.factor;
        text3.y = 90 * gameInfo.factor;

        container.addChild(text3);

        gameInfo.btnActionsContainer = container;

        let rect5 = new createjs.Graphics().beginFill("#000000aa").drawRoundRect(0, 0, 645 * gameInfo.factor, 162 * gameInfo.factor, 25 * gameInfo.factor),
            rect6 = new createjs.Shape(rect5);

        rect6.x = container.x + 70 * gameInfo.factor;
        rect6.y = container.y + 39 * gameInfo.factor;
        rect6.alpha = 0;

        gameInfo.stage.addChild(rect6);

        gameInfo.inputMedalDisableShape = rect6;
    },
    initOtherActions = gameInfo => {
        let rankIcon = new createjs.Bitmap(gameInfo.loader.getResult("rankIcon_" + gameInfo.lang)).set({
            scaleX: gameInfo.factor,
            scaleY: gameInfo.factor
        });

        rankIcon.x = $window.innerWidth - rankIcon.image.width * gameInfo.factor;
        rankIcon.y = gameInfo.tea.y + (gameInfo.tea.image.height + 100) * gameInfo.factor;

        gameInfo.stage.addChild(rankIcon);

        rankIcon.addEventListener("click", e => {
            gameInfo.goRank();
        });

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let logsIcon = new createjs.Bitmap(gameInfo.loader.getResult("logsIcon_" + gameInfo.lang)).set({
            scaleX: gameInfo.factor,
            scaleY: gameInfo.factor
        });

        logsIcon.x = $window.innerWidth - logsIcon.image.width * gameInfo.factor;
        logsIcon.y = gameInfo.tea.y + (gameInfo.tea.image.height + rankIcon.image.height + 100) * gameInfo.factor;

        gameInfo.stage.addChild(logsIcon);

        logsIcon.addEventListener("click", e => {
            gameInfo.goRecord();
        });
    },
    initHomeSelectMask = homeInfo => {
        let hovelMask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(0, 510 * homeInfo.factor, homeInfo.hovel.image.width * homeInfo.factor, homeInfo.hovel.image.height * homeInfo.factor));

        hovelMask.alpha = 0.01;

        homeInfo.stage.addChild(hovelMask);

        hovelMask.addEventListener("click", e => {
            homeInfo.homeClick(1);
        });

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let loungeMask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect((homeInfo.hovel.image.width + 20) * homeInfo.factor, 600 * homeInfo.factor, homeInfo.lounge.image.width * homeInfo.factor, homeInfo.lounge.image.height * homeInfo.factor));

        loungeMask.alpha = 0.01;

        homeInfo.stage.addChild(loungeMask);

        loungeMask.addEventListener("click", e => {
            homeInfo.homeClick(2);
        });

        let officeMask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect($window.innerWidth - homeInfo.office.image.width * homeInfo.factor, 520 * homeInfo.factor, homeInfo.office.image.width * homeInfo.factor, homeInfo.office.image.height * homeInfo.factor));

        officeMask.alpha = 0.01;

        homeInfo.stage.addChild(officeMask);

        officeMask.addEventListener("click", e => {
            homeInfo.homeClick(3);
        });

        let speakMask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(0, (homeInfo.hovel.image.height + 520) * homeInfo.factor, homeInfo.speak.image.width * homeInfo.factor, homeInfo.speak.image.height * homeInfo.factor));

        speakMask.alpha = 0.01;

        homeInfo.stage.addChild(speakMask);

        speakMask.addEventListener("click", e => {
            homeInfo.homeClick(4);
        });

        let laundryMask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect((homeInfo.speak.image.width + 20) * homeInfo.factor, (homeInfo.hovel.image.height + 710) * homeInfo.factor, homeInfo.laundry.image.width * homeInfo.factor, homeInfo.laundry.image.height * homeInfo.factor));

        laundryMask.alpha = 0.01;

        homeInfo.stage.addChild(laundryMask);

        laundryMask.addEventListener("click", e => {
            homeInfo.homeClick(5);
        });

        let studioMask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect($window.innerWidth - homeInfo.studio.image.width * homeInfo.factor, (homeInfo.hovel.image.height + 710) * homeInfo.factor, homeInfo.studio.image.width * homeInfo.factor, homeInfo.studio.image.height * homeInfo.factor));

        studioMask.alpha = 0.01;

        homeInfo.stage.addChild(studioMask);

        studioMask.addEventListener("click", e => {
            homeInfo.homeClick(6);
        });

        if (!checkLumingAuto().lumingauto) {
            return;
        }

        let teaMask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect(0, homeInfo.speak.y + homeInfo.speak.image.height * homeInfo.factor, homeInfo.tea.image.width * homeInfo.factor, homeInfo.tea.image.height * homeInfo.factor));

        teaMask.alpha = 0.01;

        homeInfo.stage.addChild(teaMask);

        teaMask.addEventListener("click", e => {
            homeInfo.homeClick(7);
        });

        let musicMask = new createjs.Shape(new createjs.Graphics().beginFill("#ffffff").drawRect((homeInfo.tea.image.width + 20) * homeInfo.factor, homeInfo.laundry.y + (homeInfo.laundry.image.height + 180) * homeInfo.factor, homeInfo.music.image.width * homeInfo.factor, homeInfo.music.image.height * homeInfo.factor));

        musicMask.alpha = 0.01;

        homeInfo.stage.addChild(musicMask);

        musicMask.addEventListener("click", e => {
            homeInfo.homeClick(8);
        });
    },
    util = {
        AsciiToString: AsciiToString,
        urlDecode: urlDecode,
        getUrlParams: getUrlParams,
        getFactor: getFactor,
        monkeyWalkT: monkeyWalkT,
        initBackground: initBackground,
        initTitle: initTitle,
        initMyInputContainer: initMyInputContainer,
        initJoinBoxContainer: initJoinBoxContainer,
        initEvadedFail: initEvadedFail,
        initEvadedSuccess: initEvadedSuccess,
        initEvadedWait: initEvadedWait,
        initHomeMedal: initHomeMedal,
        initHovel: initHovel,
        initHovelText: initHovelText,
        initOffice: initOffice,
        initOfficeText: initOfficeText,
        initLounge: initLounge,
        initLoungeText: initLoungeText,
        initSpeak: initSpeak,
        initSpeakText: initSpeakText,
        initLaundry: initLaundry,
        initLaundryText: initLaundryText,
        initStudio: initStudio,
        initStudioText: initStudioText,
        initTea: initTea,
        initTeaText: initTeaText,
        initMusic: initMusic,
        initMusicText: initMusicText,
        initDoors: initDoors,
        initKiller: initKiller,
        initMonkey: initMonkey,
        initBtnActions: initBtnActions,
        initOtherActions: initOtherActions,
        initHomeSelectMask: initHomeSelectMask
    };

export default util;